home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8504 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.microsoft.com!news
  2. From: a-cnadc@microsoft.com (Dann Corbit)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Why is Gets() so bad?
  5. Date: 4 Mar 1996 19:19:16 GMT
  6. Organization: Microsoft Corporation
  7. Message-ID: <4hffnk$m6e@news.microsoft.com>
  8. References: <4hb1ie$pa7@ixnews2.ix.netcom.com>
  9. NNTP-Posting-Host: 157.57.171.202
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <4hb1ie$pa7@ixnews2.ix.netcom.com>, studwoof@ix.netcom.co says...
  14. >
  15. >Hi.. I'm not a newbie.. I don't even use Gets(), fgets(), or scanf.. I
  16. >use my own getstring function. My question is that everywhere I see
  17. >that gets() is bad. Why exactly is it so bad? Could someone please
  18. >explain in more detail than what the FAQ does? Thanks.
  19. A big problem with gets() is that it does not know how big your input
  20. string is.  So if you have a string 12 bytes long, and you read in 13,
  21. you are doing a tap dance on your data.  The fgets() function knows how
  22. big your data object is (unless you lie to it) and is therefore much
  23. safer.
  24. -- 
  25. The opinions expressed in this message are my own personal views
  26. and do not reflect the official views of Microsoft Corporation.
  27. In fact, I'm just a subcontractor, not an employee, so pull in your claws.
  28.  
  29.